class Domino
	attr_accessor :head, :tail, :spinner
	
	def initialize(x,y, spinner = false)
		@my_nums = [x,y]
		@spinner = spinner
		@tail,@head = x,y	#default --should be oriented by the board 
	end
	
	def ==(other)
		a,b = self.to_a, other.to_a
		a == b or a == b.reverse
	end
	
	def to_s
		s="#{[tail, head]}"
		s << "(s)" if spinner
		s
	end
	
	def to_a
		@my_nums
	end
	
	def is_double?
	  @head == @tail
	end
	
	def value
		@head + @tail
	end
	
	def adj_value
	  (@head - @tail).abs
	end
	
	def orient_with!(other)
	  if other.head == self.head
	    self.flip!
	    self
	  elsif other.head == self.tail
	    self
	  else
	    false
	  end
	end
	
	def flip!
	  tmp = @head
	  @head = @tail
	  @tail = tmp
	end
	
	def dup
		Domino.new @tail, @head, @spinner
	end

end